'''
@Author: your name
@Date: 2020-01-10 09:35:50
@LastEditTime : 2020-01-13 15:12:28
@LastEditors  : Please set LastEditors
@Description: In User Settings Edit
@FilePath: \IntelligentElderlyCare\server\register\buss_mis\friends_circle_register.py
'''
from ...pao_python.pao.service.data.mongo_db import N
from ...service.security_module import SecurityModule, FunctionName, PermissionName
from ...service.buss_mis.friends_circle import FriendsCircleService
# -*- coding: utf-8 -*-
'''
老友圈管理注册
'''


def register(jsonrpc, db_addr, db_port, db_name, db_user, db_pwd, inital_password, session):
    friends_circle_func = FriendsCircleService(
        db_addr, db_port, db_name, db_user, db_pwd, inital_password, session)

    @jsonrpc.method('IFriendsCircleService.get_friends_circle_list')
    def __get_friends_circle_list(condition, page=None, count=None):
        '''获取老友圈广场列表'''
        res = friends_circle_func.get_friends_circle_list(
            condition, page, count)
        return res

    @jsonrpc.method('IFriendsCircleService.update_friends_circle')
    def __update_friends_circle(content, picture, location=None):
        """ 发布老友圈 """
        res = friends_circle_func.update_friends_circle(
            content, picture, location)
        return res

    @jsonrpc.method('IFriendsCircleService.delete_friends_circle')
    def __delete_friends_circle(friends_circle_ids):
        '''删除老友圈接口'''
        res = friends_circle_func.delete_friends_circle(friends_circle_ids)
        return res

    @jsonrpc.method('IFriendsCircleService.update_commont')
    def __update_commont(fcm_id, common):
        ''' 发布评论 '''
        res = friends_circle_func.update_commont(fcm_id, common)
        return res

    @jsonrpc.method('IFriendsCircleService.del_commont')
    def __del_commont(comment_ids):
        ''' 删除评论 '''
        res = friends_circle_func.del_commont(comment_ids)
        return res

    @jsonrpc.method('IFriendsCircleService.update_like')
    def __update_like(fcm_id, like_type):
        ''' 点赞 type:0 取消点赞，1点赞'''
        res = friends_circle_func.update_like(fcm_id, like_type)
        return res

    @jsonrpc.method('IFriendsCircleService.get_commont_list')
    def __get_commont_list(condition, page=None, count=None):
        '''获取老友圈评论列表'''
        res = friends_circle_func.get_commont_list(
            condition, page, count)
        return res

    @jsonrpc.method('IFriendsCircleService.get_like_list')
    def __get_like_list(condition, page=None, count=None):
        '''获取老友圈点赞列表'''
        res = friends_circle_func.get_like_list(
            condition, page, count)
        return res
